﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace WebApplication4
{
    public partial class Alta_Localidad : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlConnection conexion = new SqlConnection("Data Source=USUARIO-PC\\SQLEXPRESS;Initial Catalog=BDSAFA_01;Integrated Security=True;Pooling=False");
            conexion.Open();

            int codpais = (int)DropDownList1.SelectedIndex + 1;
            int codprovincia = (int)DropDownList2.SelectedIndex + 1;
            String nombreloc = TextBox1.Text.ToString();

            SqlCommand comando = new SqlCommand("insert into LOCALIDAD (descripcion,idPais,idProvincia) values ('" + nombreloc + "'," + codpais + "," + codprovincia + ")", conexion);

            if (comando.ExecuteNonQuery() > 0)
           //     Label1.Text = "Exito";
            //else
               // Label1.Text = "Error al grabar la BD";

            Label1.Text=DropDownList1.SelectedValue.ToString();
            
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int idPais = 1;
        }

        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }


    }
}